package com.yikome.storehouse.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.yikome.common.CommonRepository;
import com.yikome.storehouse.entity.Storehouse;

@Repository
public interface StorehouseRepository extends CommonRepository<Storehouse, Long>{

	@Query("select t from Storehouse t where t.yn = 1")
	List<Storehouse> findStorehouse();

	@Query("select t from Storehouse t where t.yn = 1 and t.id = :storehouseId")
	Storehouse findStorehouse(@Param("storehouseId")Long storehouseId);

	@Query("select t from Storehouse t where t.yn = 1 and t.isDefault = 1")
	Storehouse findDefaultStorehouse();

	@Query("select t from Storehouse t where t.yn = 1 and t.managers like :userName")
	List<Storehouse> findManagerStorehouse(@Param("userName")String userName);

	@Query("select t from Storehouse t where t.yn = 1 and t.isClear = 1 and t.primarryStorehouseId = :storehouseId")
	Storehouse findClearStorehouse(@Param("storehouseId")Long storehouseId);

}
